import { PointerEvent } from 'leafer-ui'
import { events } from '../utils/emit';
export class MenuEvent {
    name = 'MenuEvent'
    constructor(instance) {
        this.instance = instance;
        this.downListener = null;
        this.upListener = null;
    }

    MenuEvent() {
        return {
            handles: (callback) => {
                this.upListener = (e) => {
                    if (e.target !== this.instance.app) {
                        events.emit('menu_event', e.target);
                    } else {
                        events.emit('menu_event', false);
                    }
                };
                this.instance.app.on(PointerEvent.MENU, this.upListener);
            }
        };
    }
}